package com.yxh.view.dashedcircularprogress;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

import com.yxh.ZybApplication;
import com.yxh.util.AppUtils;

/**
 * @author Adrián García Lomas
 */
public class IconPainter implements Painter {

	private Bitmap image;
	private int centreX;
	private int centreY;
	private int imgWidth = 12;
	private int imgHeight = 12;

	public IconPainter(Bitmap image) {
		this.image = image;
		imgWidth = (int)AppUtils.getScaledDensity(ZybApplication.getContext()) * 12;
		imgHeight = (int)AppUtils.getScaledDensity(ZybApplication.getContext()) * 12;
	}

	private void initBitmap() {
	
		
		image = Bitmap.createScaledBitmap(image, imgWidth, imgHeight, true);
	}

	@Override
	public void draw(Canvas canvas) {
		initBitmap();
		canvas.drawBitmap(image, centreX, 0, new Paint());
	}

	@Override
	public void setColor(int color) {
		// Empty
	}

	@Override
	public int getColor() {
		return 0;
	}

	@Override
	public void onSizeChanged(int height, int width) {
		// this.width = width;
		// this.height = height;
		this.centreX = (width - imgWidth) / 2;
		this.centreY = (height - imgHeight) / 2;
	}

	public void setImage(Bitmap image) {
		this.image = image;
	}
}
